<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script type="text/javascript">
        function compare(x, y) {  
            var z = 0;  
            var s = x.length + y.length;;  
        
            x.sort();  
            y.sort();  
            var a = x.shift();  
            var b = y.shift();  
  
        while(a !== undefined && b !== undefined) {  
            if (a === b) {  
                z++;  
                a = x.shift();  
                b = y.shift();  
            } else if (a < b) {  
                a = x.shift();  
            } else if (a > b) {  
                b = y.shift();  
            }  
        }  
        return z/s * 100;  
    }  
  
    console.log(compare(['123', '中文', 'hello'], ['123', '中文', 'hello']))  
    console.log(compare(['123', '中文', 'hello'], ['123', '中文', 'hello'].sort()))  
    console.log(compare(['123', '中文', 'hello'], ['123', '中文', 'hello'].reverse()))  
    console.log(compare(['123', '中文', 'hello','中2文'], ['12', '中2文', '123','中文3']))  
    console.log(compare(['123', '中文', 'hello'], ['中文', 'world', '456']))  
    console.log(compare(['123', '中3文', 'hello'], ['中文', 'world', '汉字']))  
           
    </script>
</head>
<body>
    
</body>
</html>